package com.bw.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bw.domain.SysLog;
import com.bw.log.Log;
import com.bw.service.SysLogService;
import com.bw.utils.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author bobo棒
 * @date 2024年03月09日 10:32
 */

@RequestMapping("log")
@RestController
public class LogController {
    @Autowired
    SysLogService sysLogService;

    @Log
    @RequestMapping("list")
    public Result list(){

        //按日志访问日期倒序显示
        LambdaQueryWrapper<SysLog> wrapper = new LambdaQueryWrapper<>();
        wrapper.orderByDesc(SysLog::getTime);
        List<SysLog> list = sysLogService.list(wrapper);

        return Result.success(list);
    }
}
